/*
 * -------------------------------------------------------------------------------------------------------*
 * SBS Priceboard V2.0
 * Copyright (C) 2008 Unicom Vietnam JSC
 * -------------------------------------------------------------------------------------------------------* 
 * HeadURL: http://192.168.1.4/svn/priceboard/trunk/SBS_PriceboardV2/front-end/end-user/ipriceboard/
 * LastChangeBy: quanhm
 * LastChangeDate: Aug 11, 2008
 */
package com.unicom.priceboard.util;

import java.io.FileWriter;
import java.io.IOException;
import java.util.List;

import com.unicom.priceboard.data.vo.SecurityElement;

/**
 * Creation date: Aug 11, 2008
 * @author quan
 */
public class ExportXML {
	
	
	/**
	 * <b>Export OpenPrice.xml for caching Open price,ceiling,floor
	 * @param openPricePath
	 * @param openPrice
	 * @throws IOException
	 */
	public static void writeXml(String openPricePath, List<SecurityElement> openPrice)throws IOException{
		FileWriter Os =new FileWriter(openPricePath);
		Os.write("<?xml version=\"1.0\" ?>");
		Os.write("<Price>\n");
		for(SecurityElement se :openPrice)	{			
			Os.write("<STOCK>\n");
			Os.write("<Symbol_code>"+se.getSymbolCode()+"</Symbol_code>\n");
			Os.write("<openprice>"+se.getOpenPrice()+"</openprice>\n");
			Os.write("<Ceil>"+se.getCeiling()+"</Ceil>\n");
			Os.write("<Floor>"+se.getFloor()+"</Floor>\n");
			Os.write("<Refprice>"+se.getPriorClosePrice()+"</Refprice>\n");
			Os.write("</STOCK>\n");
		}
		Os.write("</Price>");
		Os.flush();
		Os.close();
	}
}
